// pages/eactive/eactive.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bghei:app.globalData.winheight/6,
    bg2hei:app.globalData.winheight/1.1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var openid = wx.getStorageSync('openid')
    wx.request({
      url: 'https://www.juquduo.com/juquduo/activity/users/my_events',
      data:{
        openid:openid
      },
      success(res){
        console.log(res)

        var newlie = []
        var date = new Date()
        for (var i = 0; i < res.data.length; i++) {
          var ActivityName = res.data[i].ActivityName
          var date = new Date(res.data[i].ActivityDate*1000)
          var Y = date.getFullYear() + '-';
          var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
          var D = date.getDate() + ' ';var h = date.getHours() + ':';
          var m = (date.getMinutes()+1 < 10 ? '0'+(date.getMinutes()) : date.getMinutes());
          console.log(Y+M+D+h+m);var time =  Y+M+D+h+m
          var item = { ActivityName: ActivityName, time: time };
          newlie = newlie.concat(item);
        }
        that.setData({aclist:res.data})
      }
    })

  },
  fabu(e){
    console.log(e)
    var pointkey = e.currentTarget.dataset.key
    wx.request({
      url: 'https://www.juquduo.com/juquduo/activity/company/release_activity',
      data:{
        activityId:pointkey.ActivityId,
        // activityDate:pointkey.ActivityDate,
        activityDate:'1603857660',
        activityType:pointkey.ActivityType,
        activityName:pointkey.ActivityName,
        IsRelease:'2'
      },
      success(res){
        console.log(res)
      }
    })
  }
})